package cn.tedu._04mybits.mapper;

import cn.tedu._04mybits.pojo.entity.Weibo;
import cn.tedu._04mybits.pojo.vo.*;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface WeiboMapper {
    //@Insert("INSERT INTO weibo(content,created,user_id) VALUES (#{content},#{created},#{userId})")
    int insertWeibo(Weibo weibo);

    //@Delete("DELETE FROM weibo WHERE id=#{id}")
    int deleteWeiboByID(Long id);

    //@Update("UPDATE weibo SET content=#{content},created=#{created},user_id=#{userId} WHERE id=#{id}")
    int updateWeiboById(Weibo weibo);

    //@Select("SELECT id,content,user_id userId FROM weibo WHERE user_id=#{uid}")
    List<Weibo> selectWeiboById(Long uid);

    //@Select("SELECT content,created FROM weibo WHERE id=#{id}")
    WeiboVO1 selectWeiboVO1ById(Long id);

    //@Select("SELECT u.username username,w.content content,w.created created FROM weibo w JOIN user u ON w.user_id=u.id WHERE u.id=#{id}")
    List<WeiboVO2> selectWeiboVO2ById(Long id);

    int dynamicUpdate(Weibo weibo);

    //动态删除:集合形势删除指定微博
    int dynamicDelete(ArrayList<Long> ids);
    //动态删除:数组形势删除指定微博
    int dynamicDelete2(Long[] ids);

    int selectCount();
    ResultMapVO1 selectMap1(Long id);

    List<ResultMapVO2> selectMap2(Long uid);
    List<ResultMapVO3> selectMap3(Long wid);
    List<ResultMapVO4> selectMap4(Long wid);
}
